import { S } from '../../s';
import { IPSControl } from '../ipscontrol';
import { PSAjaxControlContainerImpl } from '../psajax-control-container-impl';
import { IPSDBPortletPart } from './ipsdbportlet-part';
import { IPSLayoutPos } from '../layout/ipslayout-pos';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysImage } from '../../res/ipssys-image';
import { IPSSysUniRes } from '../../security/ipssys-uni-res';
import { IPSUIActionGroup } from '../../view/ipsuiaction-group';

export class PSDBPortletPartImpl
  extends PSAjaxControlContainerImpl
  implements IPSDBPortletPart
{
  get actionGroupExtractMode(): 'ITEM' | 'ITEMS' {
    return this.M.actionGroupExtractMode;
  }

  protected contentpscontrol: IPSControl;
  getContentPSControl(): IPSControl | null {
    if (this.contentpscontrol != null) return this.contentpscontrol;
    const value = this.M.getContentPSControl;
    if (value == null) {
      return;
    }
    this.contentpscontrol = this.findPSControl(value);
    return this.contentpscontrol;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0.0;
  }

  protected pslayoutpos: IPSLayoutPos;
  getPSLayoutPos(): IPSLayoutPos | null {
    return (
      this.pslayoutpos ||
      (this.pslayoutpos = this.fillObjectModel(
        S._299,
        this.M.getPSLayoutPos,
        S._2e9,
      ) as IPSLayoutPos)
    );
  }

  protected pssysimage: IPSSysImage;
  getPSSysImage(): IPSSysImage | null {
    return (
      this.pssysimage ||
      (this.pssysimage = this.fillObjectModel(
        S._27b,
        this.M.getPSSysImage,
        S._2ad,
      ) as IPSSysImage)
    );
  }

  protected pssysunires: IPSSysUniRes;
  getPSSysUniRes(): IPSSysUniRes | null {
    return (
      this.pssysunires ||
      (this.pssysunires = this.fillObjectModel(
        S._284,
        this.M.getPSSysUniRes,
        S._32d,
      ) as IPSSysUniRes)
    );
  }

  protected psuiactiongroup: IPSUIActionGroup;
  getPSUIActionGroup(): IPSUIActionGroup | null {
    return (
      this.psuiactiongroup ||
      (this.psuiactiongroup = this.fillObjectModel(
        S._210,
        this.M.getPSUIActionGroup,
        S._2ed,
      ) as IPSUIActionGroup)
    );
  }

  get portletType():
    | 'LIST'
    | 'CHART'
    | 'VIEW'
    | 'HTML'
    | 'TOOLBAR'
    | 'ACTIONBAR'
    | 'CUSTOM'
    | 'APPMENU'
    | 'CONTAINER'
    | 'RAWITEM' {
    return this.M.portletType;
  }

  get title(): string {
    return this.M.title;
  }

  get titleBarCloseMode(): 0 | 1 | 2 {
    return this.M.titleBarCloseMode != null ? this.M.titleBarCloseMode : 0;
  }

  protected titlepslanguageres: IPSLanguageRes;
  getTitlePSLanguageRes(): IPSLanguageRes | null {
    return (
      this.titlepslanguageres ||
      (this.titlepslanguageres = this.fillObjectModel(
        S._276,
        this.M.getTitlePSLanguageRes,
        S._2b1,
      ) as IPSLanguageRes)
    );
  }

  get showTitleBar(): boolean {
    return this.M.showTitleBar;
  }
  get cls(): string {
    return 'PSDBPortletPartImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._222 || cls == S._223 || cls == S._ac) return true;
    return super.instanceof(cls);
  }
}
